package it.prova.elementedit;

import it.prova.Consts;

import org.eclipse.jst.jsf.common.dom.TagIdentifier;
import org.eclipse.jst.pagedesigner.elementedit.AbstractElementEditFactory;
import org.eclipse.jst.pagedesigner.elementedit.IElementEdit;

@SuppressWarnings("restriction")
public class MyElementEditFactory extends AbstractElementEditFactory
{	
	public MyElementEditFactory()
	{
		super(null);
	}
	
	public MyElementEditFactory(final String uri)
	{
		super(uri);
	}
	
	@Override
	public IElementEdit createElementEdit(TagIdentifier tag)
	{
		if
		(
//			"Value".equals(tag.getTagName()) ||
//			"Label".equals(tag.getTagName())
			Consts.URI_DATAUNIT.equals(tag.getUri()) && 
			(
				Consts.TAG_VALUE_NAME.equals(tag.getTagName()) || 
				Consts.TAG_LABEL_NAME.equals(tag.getTagName())
			)
		)
		{
			return new DataUnitElementEdit(tag.getTagName());
		}
		else if
		(
			Consts.URI_MULTIDATAUNIT.equals(tag.getUri()) && 
			(
				Consts.TAG_VALUE_NAME.equals(tag.getTagName()) || 
				Consts.TAG_LABEL_NAME.equals(tag.getTagName())
			)
		)
		{
			return new MultiDataUnitElementEdit(tag.getTagName());
		}
		else if
		(
			Consts.URI_MULTIDATAUNIT.equals(tag.getUri()) && 
			Consts.TAG_ITERATE_NAME.equals(tag.getTagName())
		)
		{
			return new MultiDataUnitIterateElementEdit(tag.getTagName());
		}
		else if
		(
			Consts.URI_ENTRYUNIT.equals(tag.getUri()) && 
			(
				Consts.TAG_VALUE_NAME.equals(tag.getTagName()) || 
				Consts.TAG_LABEL_NAME.equals(tag.getTagName())
			)
		)
		{
			return new EntryUnitElementEdit(tag.getTagName());
		}
		else if
		(
			Consts.URI_ENTRYUNIT.equals(tag.getUri()) && 
			Consts.TAG_LINK_NAME.equals(tag.getTagName())
		)
		{
			return new EntryUnitIterateElementEdit(tag.getTagName());
		}
		return null;
	}	
}